// return number of distinct triples (i, j, k) such that a[i] + a[j] + a[k] = 0
	public static int count(double[] a) {
		int N = a.length;
		Arrays.sort(a);
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			for (int j = i+1; j < N; j++) {
				for (int k = j+1; k < N; k++) {
					int l = Arrays.binarySearch(a, -(a[i] + a[j] + a[k]));
					if (l > k) cnt++;
				}
			}
		}
		return cnt;
	}
	
